<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script type="text/javascript">
	$(function(){
		$('#opList input:checkbox').click(function(){
			var target = $(this).attr('class');
			if($(this).is(':checked')){
				$('.'+target).attr('disabled',false);				
			}else{
				$('.'+target).attr('disabled',true);				
				$(this).attr('disabled',false);
			}
		});		
		
		for(var i=0; i<'${options.size()}';i++){
			$('.opList'+i).attr('disabled',true);			
		}
		
		$('#opList input:checkbox').attr('disabled',false);
	});
</script>
<div class="detail">
	<fieldset>
	<legend>상세정보</legend>
	<table>
		<tr>
			<td>대분류 : </td>
			<td>${product.market}</td>
		</tr>
		<tr>
			<td>카테고리 : </td>
			<td>${product.category}</td>
		</tr>
		<tr>
			<td>등록일자 : </td>
			<td>${product.regidate}</td>
		</tr>
		<tr>
			<td>상품명 : </td>
			<td>${product.product}</td>
		</tr>
		<tr>
			<td>상품설명 : </td>
			<td>${product.content}</td>
		</tr>
		<tr>
			<td>판매가격 : </td>
			<td>${product.price}</td>
		</tr>
		<tr>
			<td>적립포인트 : </td>
			<td>${product.point}</td>
		</tr>
		<tr>
			<td colspan="2">
				대표 이미지 :
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<img src="<%=request.getContextPath() %>/upload/${image}" style="max-width:300px">
			</td>
		</tr>		
	</table>	
	<ul>
		<li></li>
		<li id="opList">
			<c:forEach var="i" items="${options}" varStatus="j" >
			<form:form action="optionsUpdate.do" commandName="command">
			<form:hidden value="${i.o_code}" path="o_code"/>
			<input type="hidden" value="${product.c_code}" name="c_code">
			<input type="hidden" value="${product.p_code}" name="p_code">
			<input type="hidden" value="${pageNum}" name="pageNum">
			<input type="hidden" value="${searchMarket}" name="searchMarket">
			<input type="hidden" value="${searchCategory}" name="searchCategory">
			<table>
				<tr>								
					<td>색상 <form:input class="opList${j.index}" path="color" value="${i.color}"/> </td>
					<td>사이즈 <form:input class="opList${j.index}" path="sizes" value="${i.sizes}"/> </td>
					<td>수량 <form:input class="opList${j.index}" path="quantity" value="${i.quantity}"/> </td>
					<td><input class="opList${j.index}" type="checkbox"></td>
					<td><input class="opList${j.index}" type="submit" value="수정" disabled="disabled"></td>						
					<td><input class="opList${j.index}" type="button" value="삭제" disabled="disabled" onclick="location.href='optionsDelete.do?o_code=${i.o_code}&p_code=${i.p_code}&c_code=${product.c_code}&pageNum=${pageNum}&searchMarket=${searchMarket}&searchCategory=${searchCategory}'">										
				</tr>
			</table>
			</form:form>			
			</c:forEach>
		</li>
		<li>
			<form:form action="optionsWrite.do" commandName="command">
			<input type="hidden" value="${product.c_code}" name="c_code">
			<input type="hidden" value="${product.p_code}" name="p_code"> 
			<input type="hidden" value="${pageNum}" name="pageNum"> 
			<input type="hidden" value="${searchMarket}" name="searchMarket"> 
			<input type="hidden" value="${searchCategory}" name="searchCategory"> 
			<table>
				<tr>
					<td>
						<label for="color">색상</label>
						<form:input path="color"/>
						<form:errors path="color"/></td>
					<td>
						<label for="sizes">사이즈</label>
						<form:input path="sizes"/>
						<form:errors path="sizes"/>
					</td>
					<td>
						<label for="quantity">수량</label>
						<form:input path="quantity"/>
						<form:errors path="quantity"/>
					</td>
					<td>
						&nbsp;<input type="submit" value="등록">
					</td>					
				</tr>
				<tr>
					<td colspan="4">
						<br>
						<input type="button" value="목록으로" onclick="location.href='productList.do?searchMarket=${searchMarket}&searchCategory=${searchCategory}'">
					</td>
				</tr>			
			</table>					
			</form:form>
		</li>
	</ul>
	</fieldset>
</div>